﻿using System;
using Infrastucture;
using D = System.Drawing;
using System.Windows.Media;

namespace TimeSplicerModule.DomainModels
{
    public class StatusModel : DomainObject, IDataModelConvertable<DataModels.StatusDataModel>
    {
        private Guid _statusGuid;
        private string _name;
        private string _statusEnum;
        private bool _isActive;
        private bool _isUserStatus;
        private bool _isProjectStatus;
        private bool _isBranchStatus;
        private bool _isTaskStatus;
        private int _sortOrder;
        private Status _status;
        private string _statusColor; // going to use names for now - will need to change this in the future
        private SolidColorBrush _brushColor;
        
        
        // todo: one DomainObject need enumeration update


        public Guid StatusGuid
        {
            get { return _statusGuid; }
            set { SetProperty(ref _statusGuid, value); }
        }
        public string Name
        {
            get { return _name; }
            set { SetProperty(ref _name, value); }
        }
        public string StatusEnum
        {
            get { return _statusEnum; }
            set 
            {
                SetProperty(ref _statusEnum, value);

                if (this.Status.ToString() != value)
                    this.UpdateEnumeration<Status>("Status", value);
            }
        }
        public bool IsActive 
        {
            get { return _isActive; }
            set { SetProperty(ref _isActive, value); }
        }
        public bool IsUserStatus
        {
            get { return _isUserStatus; }
            set { SetProperty(ref _isUserStatus, value); }
        }
        public bool IsProjectStatus
        {
            get { return _isProjectStatus; }
            set { SetProperty(ref _isProjectStatus, value); }
        }
        public bool IsBranchStatus
        {
            get { return _isBranchStatus; }
            set { SetProperty(ref _isBranchStatus, value); }
        }
        public bool IsTaskStatus
        {
            get { return _isTaskStatus; ; }
            set { SetProperty(ref _isTaskStatus, value); }
        }
        public int SortOrder 
        {
            get { return _sortOrder; }
            set { SetProperty(ref _sortOrder, value); }
        }
        public Status Status
        {
            get { return _status; }
            set 
            {
                SetProperty(ref _status, value);
                this.UpdateEnumerationString<Status>("StatusEnum", value);
            }
        }
        public string StatusColor
        {
            get { return _statusColor; }
            set
            {
                SetProperty(ref _statusColor, value);
                //D.Color c = D.Color.FromName(value);
                //Color co = Color.FromArgb(c.A, c.R, c.G, c.B);
                //BrushColor = new SolidColorBrush(co);
            }
        }
        public SolidColorBrush BrushColor
        {
            get { return _brushColor; }
            set { SetProperty(ref _brushColor, value); }
        }

        public DataModels.StatusDataModel ToDataModel()
        {
            return ModelConverter.ToModel<DataModels.StatusDataModel>(this);
        }

        public SolidColorBrush SetBrushColor()
        {
            D.Color c = D.Color.FromName(this.StatusColor);
            Color co = Color.FromArgb(c.A, c.R, c.G, c.B);

            return  this.BrushColor = new SolidColorBrush(co);
        }
    }
}
